/*
DirectInput framework from http://www.rastertek.com/dx11tut13.html
Date Referenced: 28/12/2012
*/

#ifndef DX11INPUTMANAGER_H
#define DX11INPUTMANAGER_H

#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")

#define DIRECTINPUT_VERSION 0x0800

#include "Singleton.h"

#include <D3DX11.h>
#include <D3DX10math.h>
#include <dinput.h>/////////

class DX11InputManager : public Uncopyable
{
	DX11InputManager();
	friend class Singleton<DX11InputManager>;
public:
	~DX11InputManager();
	bool Init(HINSTANCE hInstance, HWND hWnd, int screenWidth, int screenHeight);
	bool Update();

	void GetMouseLocation(int& x, int& y);
	void GetMouseLocation(D3DXVECTOR2* pos);

	//unsigned char* GetKeyPressed();
	bool GetKeyPressed(int key);
	DIMOUSESTATE& GetMouseState();
	
	bool GetTakingInput();
	void SetTakingInput(bool b);


private:
	bool ReadKeyboard();
	bool ReadMouse();
	void ProcessInput();

private:
	IDirectInput8* m_directInput;
	IDirectInputDevice8* m_keyboardDevice;
	IDirectInputDevice8* m_mouseDevice;

	unsigned char m_keyboardState[256];
	DIMOUSESTATE m_mouseState;

	int m_screenWidth, m_screenHeight;
	int m_mouseX, m_mouseY;

	int m_currentKey;
	float m_pollRate;
	float m_timer;

	bool m_takingKeyboardInput;
};

typedef Singleton<DX11InputManager> TheDX11InputManager;

#endif //DX11INPUTMANAGER_H